Crate grr

source ·
Expand description

Bare metal OpenGL 4.5+ wrapper

Overview

grr aims at providing a modern and clean looking API with focus on direct state access. The terminology used follows mostly Vulkan and OpenGL.

Initialization

The main entry point for working with the library is a Device. A device wraps an OpenGL context which needs to be created and managed externally. The documentation and examples will all use glutin for window and context management.

extern crate glutin;
extern crate grr;

use glutin::GlContext;

fn main() -> grr::Result<()> {
    let mut events_loop = glutin::EventsLoop::new();
    let window = glutin::WindowBuilder::new()
        .with_title("Hello grr!")
        .with_dimensions(1024, 768);
    let context = glutin::ContextBuilder::new()
        .with_vsync(true)
        .with_srgb(true)
        .with_gl_debug_flag(true);

    let window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
    unsafe {
        window.make_current().unwrap();
    }

    let grr = grr::Device::new(
        |symbol| window.get_proc_address(symbol) as *const _,
        grr::Debug::Enable {
            callback: |_, _, _, _, msg| {
                println!("{:?}", msg);
            },
            flags: grr::DebugReport::all(),
        },
    );

    Ok(())
}

Modules

The API has multiple concepts which interplay with each other. The main of interacting with the library is via function calls on a Device object. The calls often translate directly to one GL call. All other objects created are opaque handles!

  • Resource: Objects with associated memory. Can be a Buffer (untyped) or an Image.
  • Pipeline: There currently are two sort of pipelines suppoerted: Graphics and Compute
  • Framebuffer: Assembles the attachments (ImageView or RenderBuffer) for draw calls
  • Sampler: Configures image filtering. An Image is bound together with a Sampler to a texture unit for access in a shader stage.
  • Vertex Array: Specifies the vertex attributes and bindings for the input assembler stage. Buffers are bound to a VertexArray to declare the memory region to fetch attribute data from.

Structs

Memory barrier.
Debug report flags.
Logical device, representation one or multiple physical devices (hardware or software).
Framebuffer handle.
Graphics Pipeline Descriptor.
Image resource handle.
Image view handle.
Input Assembly Descriptor.
Memory mapping flags.
Memory property flags.
Graphics or Compute pipeline.
Memory barrier for by-region dependencies.
Renderbuffer handle.
Sampler handle.
Sampler Descriptor.
Shader.
Subresource of an image.
Vertex array handle.
Buffer representation for vertex attributes
Viewport transformation.

Enums

Attachment reference.
Attachment clearing description.
Comparison operator.
Uniform constant.
Device debug control.
Debug message source.
Debug message type.
Error return codes
Image dimensionality type.
Index size.
Vertex attribute addresssing.
Primitve topology.
Sampler addressing mode.
Shader Stages.
Vertex attribute formats.

Functions

View a slice as raw byte slice.

Type Definitions

A specialized Result type for grr operations.